<extend name="work/base" />
<block name="content">
    <form class="layui-form inline-form">
        <div class="pull-left">
            <div class="layui-inline dropdown">
                <input name="title" class="layui-input" type="text" id="doctitle" placeholder="名称">
            </div>
            <div class="layui-inline">
                <button class="layui-btn  layui-btn-normal" lay-submit lay-filter="docsearch_btn"><i
                        class="layui-icon">&#xe615;</i>搜索
                </button>
            </div>
            <div class="layui-inline">
                <button class="layui-btn layui-btn-normal  ajax-form"
                        data-url="{:url('notify_add')}"><i
                        class="layui-icon">&#xe61f;</i> 新增
                </button>
            </div>
        </div>
    </form>
    <table class="layui-table text-center" id="list" lay-filter="list"
           list-url="{:url('lists')}"
           edit-url="{:url('notify_edit')}"
           del-url="{:url('notifydelete')}"
           forms-url="{:url('notifyview')}"
    ></table>

</block>
<block name="script">
    <script charset="utf-8" src="https://unpkg.com/qiniu-js@2.5.4/dist/qiniu.min.js"></script>
    <script type="text/html" id="barDemo">
        <a class="layui-btn  layui-btn-xs " lay-event="forms" forms-url="{:url('notifyview')}"><i class="fa fa-pencil"></i>查看</a>
        <a class="layui-btn  layui-btn-xs " lay-event="edit"><i class="fa fa-pencil"></i> 编辑</a>
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delete"> <i class="fa fa-trash-o"></i> 删除</a>
    </script>
    <script type="text/javascript">
        layui.use(['element', 'table', 'form', 'tree'], function () {
            var table = layui.table
                , element = layui.element
                ,$=layui.$
                , form = layui.form;
            table.render({
                elem: '#list'
                , url: "{:Url('lists')}"
                , page: true
                , loading: true
                ,limit:20
                , cols: [[
                    {field: 'category', width: 110,title: '分类'}
                    ,{field: 'title', title: '标题'}
                    , {fixed: 'right', width: 220, title: '操作', toolbar: '#barDemo'}
                ]]
            });
            //监听单元格事件
            form.on('submit(docsearch_btn)', function (data) {
                table.reload('list', {
                    url: "{:Url('lists')}"
                    , page: {
                        curr: 1
                    }
                    , where: data.field
                });
                return false;
            });
            form.on('select(doc_type)', function (data) {
                table.reload('list', {
                    url: "{:Url('lists')}"
                    , page: {
                        curr: 1
                    }
                    , where: {
                        status: data.value
                    }
                });
                return false;
            });
        });
    </script>
</block>
